<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp"%>
<script type="text/javascript" >
$(function(){
	$('#resTree').tree({
		url: ctx + '/sm/Res!findAllChildTree.action?roleId='+$('#roleId').val(),
	    fit: true,
	    multiple: true,
        checkbox: true,
	    idField: 'id',
	    treeField: 'text',
	    onLoadSuccess:function(node,data){
	    	
	    }
	});
	
	$('#roleResBack').bind('click',function(){
		comeback();
	});
	$('#roleResSave').bind('click',function(){
		var data = '';
		var cname='';
	    var nodes = $('#resTree').tree('getChecked');
	    if (nodes.length<1) {
	        $.messager.show({
	            msg: "请勾选至少一条数据"
	        });
	        return false;
	    }
	    for (var i = 0; i < nodes.length; i++) {
	        if (data == '') {
	            data = nodes[i].id;
	            cname = nodes[i].text;
	        }
	        else {
	            data = data + ',' + nodes[i].id;
	            cname = cname +','+ nodes[i].text;
	        }
	    }
	    $('#checkRes').val(data);
	    $('#checkResName').val(cname);
		CQOA.formSubmit($('#roleResForm'),ctx+'/sm/Role!saveRelationRes.action',function(o){
			if(o.success){
				comeback();
			}
			$.messager.show({
				msg : o.msg
			});
		},{});
	});
	
	
});



</script>
			<div id="easyui-title" style="display:none">
	            	角色关联资源设置
	        </div>
	        <s:form id="roleResForm">
		        <s:hidden id="checkRes" name="resIds"></s:hidden>
		        <s:hidden id="checkResName" name="resNames"></s:hidden>
		        <s:hidden id="roleId" name="roleId"></s:hidden>
		        <s:hidden id="roleName" name="roleName"></s:hidden>
	        </s:form>
	        <table class="dataTable" >
				<tr>
					<td colspan="2" style="position: relative;height: 30px;text-align: center;">
					<a href="#" class="easyui-linkbutton" iconCls="icon-back" id="roleResBack">返回</a>
                    <a href="#" class="easyui-linkbutton" iconCls="icon-save" id="roleResSave">保存</a>
                    </td>
				</tr>
				<tr>
					<td width="80px"><s:property value="roleName"/>:</td>
					<td>
						<div fit="true" border="false" style="height: 400px;overflow:auto;overflow-x:hidden">
						<ul id="resTree" class="easyui-tree"></ul>
						</div>
					</td>
				</tr>
			</table>


